import { deleteByPrimaryKeyForProTabColumnAuth, selectByPrimaryKeyForProTabColumnAuth, insertForProTabColumnAuth, updateForProTabColumnAuth, deleteByMapForProTabColumnAuth,updateByMapForProTabColumnAuth, getOneForProTabColumnAuth,getAllForProTabColumnAuth,queryPageForProTabColumnAuth, countForProTabColumnAuth, insertBatchForProTabColumnAuth, deleteBatchForProTabColumnAuth,updateBatchForProTabColumnAuth,getPageProTableColumnsByAuthId,queryPageForProAuthority,queryPageForProTableColumnChild,getSelectedProTableColumnByAuthId } from '@/services/system/api_protabcolumnauth';

export default {
    namespace: 'protabcolumnauth',

    state: {
        data: {
            list: [],
            pagination: {},
        },
        tableColumn: {
            list: [],
            pagination: {},
        },
        tableColumnChild: {
            list: [],
            pagination: {},
        },
        tableColumnSelect: {
            list: [],
        },
    },

    effects: {
            *delete_by_primarykey_for_protabcolumnauth({ payload }, { call, put }) {
                const response = yield call(deleteByPrimaryKeyForProTabColumnAuth, payload);
                yield put({
                    type: 'deleteByPrimaryKeyForProTabColumnAuth',
                    payload: response,
                });
            },
            *select_by_primarykey_for_protabcolumnauth({ payload, callback }, { call, put }) {
                const response = yield call(selectByPrimaryKeyForProTabColumnAuth, payload);
                yield put({
                    type: 'selectByPrimaryKeyForProTabColumnAuth',
                    payload: response,
                });
                if (callback) callback();
            },
            *insert_for_protabcolumnauth({ payload, callback }, { call, put }) {
                const response = yield call(insertForProTabColumnAuth, payload);
                yield put({
                    type: 'insertForProTabColumnAuth',
                    payload: response,
                });
                if (callback) callback();
            },
            *update_for_protabcolumnauth({ payload, callback }, { call, put }) {
                const response = yield call(updateForProTabColumnAuth, payload);
                yield put({
                    type: 'updateForProTabColumnAuth',
                    payload: response,
                });
                if (callback) callback();
            },
            *delete_by_map_for_protabcolumnauth({ payload, callback }, { call, put }) {
                const response = yield call(deleteByMapForProTabColumnAuth, payload);
                yield put({
                    type: 'deleteByMapForProTabColumnAuth',
                    payload: response,
                });
                if (callback) callback();
            },
            *update_by_map_for_protabcolumnauth({ payload, callback }, { call, put }) {
                const response = yield call(updateByMapForProTabColumnAuth, payload);
                yield put({
                    type: 'updateByMapForProTabColumnAuth',
                    payload: response,
                });
                if (callback) callback();
            },
            *get_one_for_protabcolumnauth({ payload, callback }, { call, put }) {
                const response = yield call(getOneForProTabColumnAuth, payload);
                yield put({
                    type: 'getOneForProTabColumnAuth',
                    payload: response,
                });
                if (callback) callback();
            },
            *get_all_for_protabcolumnauth({ payload, callback }, { call, put }) {
                const response = yield call(getAllForProTabColumnAuth, payload);
                yield put({
                    type: 'getAllForProTabColumnAuth',
                    payload: response,
                });
                if (callback) callback();
            },
            *query_page_for_protabcolumnauth({ payload, callback }, { call, put }) {
                const response = yield call(queryPageForProTabColumnAuth, payload);
                yield put({
                    type: 'queryPageForProTabColumnAuth',
                    payload: response,
                });
                if (callback) callback();
            },
            *count_for_protabcolumnauth({ payload, callback }, { call, put }) {
                const response = yield call(countForProTabColumnAuth, payload);
                yield put({
                    type: 'countForProTabColumnAuth',
                    payload: response,
                });
                if (callback) callback();
            },
            *insert_batch_for_protabcolumnauth({ payload, callback }, { call, put }) {
                const response = yield call(insertBatchForProTabColumnAuth, payload);
                yield put({
                    type: 'insertBatchForProTabColumnAuth',
                    payload: response,
                });
                
                const responsedata = yield call(queryPageForProAuthority, {});
                yield put({
                	type: 'queryPageForProAuthority',
                	payload: responsedata,
                });
                
                const newPayload = { auth_id: [payload.authids[0].id]};
                const responseTableColumn = yield call(getPageProTableColumnsByAuthId, newPayload);
                yield put({
                    type: 'getPageProTableColumnsByAuthId',
                    payload: responseTableColumn,
                });
                
                if (callback) callback();
            },
            *delete_batch_for_protabcolumnauth({ payload, callback }, { call, put }) {
                const response = yield call(deleteBatchForProTabColumnAuth, payload);
                yield put({
                    type: 'deleteBatchForProTabColumnAuth',
                    payload: response,
                });
                if (callback) callback();
            },
            *update_batch_for_protabcolumnauth({ payload, callback }, { call, put }) {
                const response = yield call(updateBatchForProTabColumnAuth, payload);
                yield put({
                    type: 'updateBatchForProTabColumnAuth',
                    payload: response,
                });
                if (callback) callback();
            },
            *get_page_protablecolumns_by_authid({ payload, callback }, { call, put }) {
                const response = yield call(getPageProTableColumnsByAuthId, payload);
                yield put({
                    type: 'getPageProTableColumnsByAuthId',
                    payload: response,
                });
                if (callback) callback();
            },
            *query_page_for_proauthority({ payload, callback }, { call, put }) {
                const response = yield call(queryPageForProAuthority, payload);
                yield put({
                    type: 'queryPageForProAuthority',
                    payload: response,
                });
                if (callback) callback();
            },
            *query_page_for_protablecolumnchild({ payload, callback }, { call, put }) {
                const response = yield call(queryPageForProTableColumnChild, payload);
                yield put({
                    type: 'queryPageForProTableColumnChild',
                    payload: response,
                });
                if (callback) callback();
            },
            *get_selected_protablecolumn_by_authid({ payload, callback }, { call, put }) {
                const response = yield call(getSelectedProTableColumnByAuthId, payload);
                yield put({
                    type: 'getSelectedProTableColumnByAuthId',
                    payload: response,
                });
                if (callback) callback();
            },
            },

    reducers: {
        deleteByPrimaryKeyForProTabColumnAuth(state, action) {
            return {
                ...state,
                data: action.payload,
            };
        },
        selectByPrimaryKeyForProTabColumnAuth(state, action) {
            return {
                ...state,
                data: action.payload,
            };
        },
        insertForProTabColumnAuth(state, action) {
            return {
                ...state,
                data: action.payload,
            };
        },
        updateForProTabColumnAuth(state, action) {
            return {
                ...state,
                data: action.payload,
            };
        },
        deleteByMapForProTabColumnAuth(state, action) {
            return {
                ...state,
                data: action.payload,
            };
        },
        updateByMapForProTabColumnAuth(state, action) {
            return {
                ...state,
                data: action.payload,
            };
        },
        getOneForProTabColumnAuth(state, action) {
            return {
                ...state,
                data: action.payload,
            };
        },
        getAllForProTabColumnAuth(state, action) {
            return {
                ...state,
                data: action.payload,
            };
        },
        queryPageForProTabColumnAuth(state, action) {
            return {
                ...state,
                data: action.payload,
            };
        },
        countForProTabColumnAuth(state, action) {
            return {
                ...state,
                data: action.payload,
            };
        },
        insertBatchForProTabColumnAuth(state, action) {
            return {
                ...state,
                data: action.payload,
            };
        },
        deleteBatchForProTabColumnAuth(state, action) {
            return {
                ...state,
                data: action.payload,
            };
        },
        updateBatchForProTabColumnAuth(state, action) {
            return {
                ...state,
                data: action.payload,
            };
        },
        queryPageForProAuthority(state, action) {
            return {
                ...state,
                data: action.payload,
            };
        },
        getPageProTableColumnsByAuthId(state, action) {
            return {
                ...state,
                tableColumn: action.payload,
            };
        },
        queryPageForProTableColumnChild(state, action) {
            return {
                ...state,
                tableColumnChild: action.payload,
            };
        },
        getSelectedProTableColumnByAuthId(state, action) {
            return {
                ...state,
                tableColumnSelect: action.payload,
            };
        },
    },
};
